package com.ghck.server.dao;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.ghck.server.dao.provider.UsersHobbyRelProvider;
import com.ghck.server.model.UsersHobbyRel;
import com.ghck.server.model.query.UsersHobbyRelQuery;
/**
 * 用户-爱好关系表  <br>
 * r_users_hobby <br>
 * v1.0 2016-05-08
 */
 public interface UsersHobbyRelMapper {
 	
 	/**
 	*根据id删除 用户-爱好关系表
 	*/
 	@Delete("delete from r_users_hobby where id=#{id}")
 	public Integer deleteById(Integer id);
 	
 	@DeleteProvider(method="deleteByIds",type=UsersHobbyRelProvider.class)
	public Integer deleteByIds(List<Integer> ids);
 	
 	/**
 	* 批量新增 用户-爱好关系表
 	*/
 	@InsertProvider(method="batchInsert",type=UsersHobbyRelProvider.class)
	@Options(useGeneratedKeys=true,keyColumn="id",keyProperty="list[0].id")
 	public Integer batchInsert(List<? extends UsersHobbyRel> usersHobbyRels);
 	
 	/**
 	* 新增 用户-爱好关系表
 	*/
 	@InsertProvider(method="insert",type=UsersHobbyRelProvider.class)
	@Options(useGeneratedKeys=true)
 	public Integer insert(UsersHobbyRel domain);
 
 	
 	/**
 	*更新 用户-爱好关系表
 	*/
 	@UpdateProvider(method="update",type=UsersHobbyRelProvider.class)
 	public Integer update(UsersHobbyRel domain);
 	
 	/**
 	*根据ID查询 用户-爱好关系表
 	*/
	@Select("select * from r_users_hobby where id=#{id}")
	public UsersHobbyRel findById(Integer id);
	
	/**
 	*通过query 查询 用户-爱好关系表
 	*/
 	@SelectProvider(method="findByQuery",type=UsersHobbyRelProvider.class)
 	public List<UsersHobbyRel> findByQuery(UsersHobbyRelQuery query);
 	
 	/**
 	*通过query count总条数
 	*/
 	@SelectProvider(method="countByQuery",type=UsersHobbyRelProvider.class)
 	public Integer countByQuery(UsersHobbyRelQuery query);
 	
 	/**
 	* 通过ids查询
 	*/
 	@SelectProvider(method="findByIds",type=UsersHobbyRelProvider.class)
 	public List<UsersHobbyRel> findByIds(List<Integer> ids);
 	
 	@SelectProvider(method="findByUserIdNames",type=UsersHobbyRelProvider.class)
 	public List<UsersHobbyRel> findByUserIdNames(@Param("names") List<String> names,@Param("userId") Integer userId);

 	@Select("select * from r_users_hobby where user_id=#{userId}")
	public List<UsersHobbyRel> findByUserId(Integer userId);
	
 }	
 